package www.webols.test.uitls;

import java.io.File;
import java.io.IOException;
import java.io.StringReader;

import www.webols.utils.StreamTool;

public class FileWriter {
	
	public static void write(String content){
		String path = android.os.Environment.getExternalStorageDirectory()
				+ "/weibols";
		File file=new File(path+"/weibo.json");
		if(file.exists()){
			file.delete();
			
		}
		try {
			file.createNewFile();
			java.io.FileWriter w=new java.io.FileWriter(file);
			w.write(content);
			w.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}	
	}
	public static String read() throws Exception{
		String path = android.os.Environment.getExternalStorageDirectory()
				+ "/weibols";
		File file=new File(path+"/weibo.json");
		try {
			file.createNewFile();
	
			byte[] data=StreamTool.readInputStream(new java.io.FileInputStream(file));
			return new String(data);
		} catch (Exception e) {
			throw e;
		}	
	}
}
